package com.xmhmyh.generalframework.common.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author: 于丁
 * @DateTime: 2021/1/20 2:23 下午
 */
public class LocalDateTimeUtils {

    public static String LocalDateTime2String(LocalDateTime localDateTime) {
        if (localDateTime == null) {
            return null;
        }
        return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public static LocalDateTime String2LocalDataTime(String time) {
        if (StringUtils.isBlank(time)) {
            return null;
        }
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime result = LocalDateTime.parse(time, df);
        return result;
    }
}
